package com.sltx.util.http;

import java.io.InputStream;
import java.util.Properties;

public class ConfigUtils {
    private static final String CONFIG_FILE = "/config.properties";
    public static final String SERVER_URL = "org.gsql.server.url";

    public static final String QUERY_TYPE = "query.data.type";

    public static String getServerUrl() {
        return getProperty(SERVER_URL, "true");
    }

    public static String getQueryType() {
        return getProperty(QUERY_TYPE, "true");
    }

    static Properties prop;

    public static String getProperty(String key, String def) {
        if (prop == null) {
            InputStream is = ConfigUtils.class.getResourceAsStream(CONFIG_FILE);
            prop = new Properties();
            try {
                prop.load(is);
            } catch (Exception e) {
                System.out.println(e);
                prop = null;
            }
        }

        return prop.getProperty(key, def);
    }

}
